<?php

/*

  Action	$4

  +1 Buy
  You may discard an Estate card.
  If you do, +$4.  Otherwise, gain an Estate card.

 */

class Baron extends Card implements iAction, iKingdom, iIntrigue {

    public function __construct() {
        parent::__construct("Baron", 4);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+1 Buy",
            " You may discard an Estate card.  If you do, +$4.  Otherwise, gain an Estate card.");
    }
    
    public function play(Game $game, $isRealCard) {
        $game->addBuys(1);
         ScreenDisplay::addScreenMessage($game, true, "get +1 buy", "gets +1 buy");

        $estate = $game->getCardInHand("Estate");
        if ($estate) {
            $options = array(new Option(1, 'Discard estate for $4?'), new Option(2, 'Gain Estate'));
            $output = MySocket::GetUserReply($game, Input_ChooseOne, $options, 1, 1, null, "Please choose");
            $answer = $output[0];

            if ($answer == "Discard estate for $4?") {
                $game->moveCardFromPileToPile("Estate", PlayHand, DiscardPile);
                $game->addMoney(new Price(4));
                 ScreenDisplay::addScreenMessage($game, true, "discard ".  nicePrint($estate), "discards ".ScreenDisplay::$LMSG);
            } else {
                $estate = $game->moveCardFromPileToPile("Estate", BoardCards, DiscardPile);
                 ScreenDisplay::addScreenMessage($game, true, "gain ".  nicePrint($estate), "gains ".ScreenDisplay::$LMSG);
            }
        }
        else {
           $estate = $game->moveCardFromPileToPile("Estate", BoardCards, DiscardPile);
             ScreenDisplay::addScreenMessage($game, true, "gain ".  nicePrint($estate), "gains ".ScreenDisplay::$LMSG);
        }
        $game->cardActionFinished();
        return true;
    }

}

?>